package com.ddm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddm.entity.Bookmark;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 丁丁猫
 * @version 1.0
 */
@Mapper
public interface BookmarkMapper extends BaseMapper<Bookmark> {

    /**
     * 根据 userId 查询收藏的 course_id
     * @param userId 用户 ID
     * @return 收藏的 course_id 列表
     */
    @Select("SELECT course_id FROM bookmark WHERE user_id = #{userId}")
    List<Integer> selectCourseIdsByUserId(Integer userId);

    @Select("SELECT bookmark.regulation_id FROM bookmark WHERE user_id = #{userId}")
    List<Integer> selectRegulationIdsByUserId(Integer userId);

    @Select("SELECT bookmark.standard_id FROM bookmark WHERE user_id = #{userId}")
    List<Integer> selectStandardIdsByUserId(Integer userId);

    @Select("SELECT bookmark.market_id FROM bookmark WHERE user_id = #{userId}")
    List<Integer> selectMarketAnIdsByUserId(Integer userId);

    /**
     * 根据 userId 查询报名的竞赛 exam_id
     * @param userId 用户 ID
     * @return 报名的竞赛 exam_id 列表
     */
    @Select("SELECT exam_id FROM bookmark WHERE user_id = #{userId} AND exam_id IS NOT NULL")
    List<Long> selectExamIdsByUserId(Long userId);

}
